const Router = require('koa-router');
const router = new Router();

// 请求用户首页
// 1. 获取banner, 分类信息 等一系列的用户界面首页的数据
router.get('', async ctx => {
    let { HTTP_ROOT } = ctx.config;
    let banners = await ctx.db.query('select * from banner_table order by serial DESC');
    let catalogs = await ctx.db.query("select * from catalog_table");
    await ctx.render('www/index', {
        HTTP_ROOT,
        banners,
        catalogs
    })
})

// 点击分类, 跳转到分类明细页面
router.get('list/:id', async ctx => {
    let {HTTP_ROOT}=ctx.config;
    await ctx.render('www/list', {
        HTTP_ROOT
    })
})


module.exports = router.routes();